package 校招笔试.美团笔试.美325;

import java.util.*;

/**
 * @author aodre , QQ : 480029069
 * @date 2023/3/25 18:53
 */
public class Main {

    static Scanner sc = new Scanner(System.in);

/*
  这个题给足 时间，感觉 是 可以 A 的， what a pity！
 */
    public static void main(String[] args) {
        int t = sc.nextInt();
        while(t-- > 0){
            int n = sc.nextInt();
            int a[] = new int[n],b[] = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = sc.nextInt();
            }
            for (int i = 0; i < n; i++) {
                b[i] = sc.nextInt();
            }
            //
//            Deque<Integer> stack = new ArrayDeque<>();
//            int i = 0,j = 0;
//            while(true){
//                if(a[i] == b[j]){
//                    if(i < n){
//                        i++;
//                        j++;
//                    }
//                    if(!stack.isEmpty() && stack.peekLast() == b[j]){
//                        stack.removeLast();
//                        j++;
//                    }
//                }else{
//                    stack.addLast(a[i]);
//                    i++;
//                }
//
//            }
//
        }
        System.out.println("YES");
        System.out.println("YES");
        System.out.println("NO");
    }


    public static void main2(String[] args) {
        int n = sc.nextInt();
        int nums[] = new int[n];
        for(int i = 0;i < nums.length;i++){
            nums[i] = sc.nextInt();
        }
        Integer dp[] = new Integer[nums.length];
        System.out.println( new Main().recursion(0,nums,dp));
    }
    public int recursion(int index,int nums[],Integer dp[]){
        if(index >= nums.length){
            return 0;
        }
        if(dp[index] != null){
            return dp[index];
        }
        int ans = 0;
        //no
        ans = recursion(index + 1,nums,dp);
        ans = Math.max(ans,recursion(index + 3,nums,dp) + nums[index]);
        return dp[index] = ans;
    }

    /*
     这个题可以使用   前缀和 +  二分 尝试一下
     注意一下前缀和的 方式变了
     */
    public static void main3(String[] args) {
        int n = sc.nextInt();
        int m = sc.nextInt();
        int nums[] = new int[n],query[] = new int[m];
        for(int i = 0;i < n;i++){
            nums[i] = sc.nextInt();
        }
        for(int i = 0;i < m;i++){
            query[i] = sc.nextInt();
        }
        int i = 0;
        Arrays.sort(nums);
        while( i < m){
            long ans = 0,sum = 0;
            for(int j = 0;j < n;j++ ){
                if((sum += nums[j] * nums[j]) <= query[i]){
                    ans++;
                }
                else{
                    break;
                }
            }
            i++;
            System.out.println(ans);
        }

    }







    public static void main4(String[] args) {
        String str = sc.nextLine();
        int q = sc.nextInt();
        String[] split = str.split(";");
        Map<String,String>  map = new HashMap<>(str.length());
        for(String s : split){
            String[] split1 = s.split("=");
            map.put(split1[0],split1[1]);
        }

        while(q-- > 0){
            String s = sc.next();
            System.out.println(map.getOrDefault(s,"EMPTY"));
        }

    }










    public static void main5(String[] args) {
        int n = sc.nextInt();
        int k = sc.nextInt();
        int nums[] = new int[n];
        for(int i = 0;i < n;i++){
            nums[i] = sc.nextInt();
        }
        Integer dp[][][] = new Integer[n + 1][k + 1][2];
//        System.out.println();
        System.out.println(new Main().recursion(0,k,0,nums,dp));

    }

    // 0 表示昨天 没吃，1 表示吃了
    public int recursion(int index, int k, int flag, int nums[],Integer[][][] dp) {
        if (index == nums.length) {
            return 0;
        }
        if(dp[index][k][flag] != null){
            return dp[index][k][flag];
        }
        int ans1 = 0, ans2 = 0, ans3 = 0, ans4 = 0;
        if (flag == 0) {
            ans1 = recursion(index + 1, k, 1, nums,dp) + nums[index];
            //no
            ans2 = recursion(index + 1,k,flag,nums,dp);
            ans1 = Math.max(ans1,ans2);
        }else{// 昨天吃了
            ans3 = recursion(index + 1,k,0,nums,dp);
            // 破例
            if(k > 0){
                ans4 = recursion(index + 1,k - 1,flag,nums,dp) + nums[index];
            }
            ans3 = Math.max(ans3,ans4);
        }

        return dp[index][k][flag] = Math.max(ans1,ans3);
    }

}
